import request from '@/sheep/request';
import sheep from "@/sheep";

export default {
  // 商品详情
  detail: (id, data) => {
    let storagePlatform = uni.getStorageSync('platform');

    let platform = 0

    if (storagePlatform === 0 || storagePlatform === 1) {
      platform = storagePlatform
    } else {
      platform = 0
    }
    if (!sheep.$helper.isRealEmpty(data.platform)) {
      // 参数内平台类型存在直接用参数内的
      platform = data.platform
    }

    console.log('商品平台', platform, data)
    return request({
      url: 'no-auth/product/detail/' + platform + '/' + id,
      method: 'GET',
      custom: {
        showLoading: false,
        showError: false,
      },
    })
  },


  // 商品列表
  list: (data, params) => {
    let storagePlatform = uni.getStorageSync('platform');

    let platform = 0

    if (storagePlatform === 0 || storagePlatform === 1) {
      platform = storagePlatform
    } else {
      platform = 0
    }
    if (!sheep.$helper.isRealEmpty(data.platform)) {
      // 参数内平台类型存在直接用参数内的
      platform = data.platform
    }

    console.log('商品平台', platform, data)
    return request({
      url: 'no-auth/product/list/' + platform,
      method: 'post',
      data,
      params,
      custom: {
        showLoading: false,
        showError: true,
      },
    })
  },

  // 商品详情 - 预售商品
  detailPre: (id, data) => {
    return request({
      url: 'no-auth/product/detailPre/' + id,
      method: 'GET',
      custom: {
        showLoading: false,
        showError: false,
      },
    })
  },


  // 商品列表 - 预售商品
  listPre: (data, params) => {
    return request({
      url: 'no-auth/product/listPre/',
      method: 'post',
      data,
      params,
      custom: {
        showLoading: false,
        showError: true,
      },
    })
  },

  // 商品查询
  ids: (params = {}) =>
      request({
        url: 'goods/goods/ids',
        method: 'GET',
        params,
        custom: {
          showLoading: false,
          showError: false,
        },
      }),

  // 商品评价列表
  comment: (data) =>
      request({
        url: '/no-auth/mercari/auto/comments/fetch/feign',
        method: 'POST',
        data: data,
        custom: {
          showLoading: false,
          showError: false,
        },
      }),
  // 详情翻译
  translate: (data) =>
      request({
        url: '/no-auth/product/translate',
        method: 'POST',
        data: data,
        custom: {
          showLoading: false,
          showError: false,
        },
      }),
  // 卖家详情
  sellerInfo: (data) =>
      request({
        url: '/no-auth/mercari/auto/sellerInfo/fetch/feign',
        method: 'POST',
        data: data,
        custom: {
          showLoading: false,
          showError: false,
        },
      }),
  // 商品评价列表
  commentAdd: (data) =>
      request({
        url: '/h5/pms/productComments',
        method: 'POST',
        data: data
      }),
  // 评论积分支付
  commentPayByScore: (data) =>
      request({
        url: '/h5/pms/productComments/commentPay',
        method: 'POST',
        data: data
      }),
  // 商品评价列表
  getPlatformComments: (params) =>
      request({
        url: '/h5/pms/productComments/list',
        method: 'GET',
        params: params
      }),
  // 预售商品列表
  preGoodsList: (params) =>
      request({
        url: '/no-auth/h5/brand/all',
        method: 'GET',
        params: params
      }),
  // 商品评价类型
  getType: (id) =>
      request({
        url: 'goods/comment/getType/' + id,
        method: 'GET',
        custom: {
          showLoading: false,
          showError: false,
        },
      }),
  // 活动商品查询
  // 商品查询
  activity: (params = {}) =>
      request({
        url: 'goods/goods/activity',
        method: 'GET',
        params,
        custom: {
          showLoading: false,
          showError: false,
        },
      }),
  activityList: (params = {}) =>
      request({
        url: 'goods/goods/activityList',
        method: 'GET',
        params,
      }),


};
